<template>
	<!-- 人员管理 -->
	<view class="wp">
		<view class="nav_bar">
			<!-- <view style="color: #777; font-size: 28rpx;">
				<text>提示：以下为您的直推用户，可授权为业务经理</text>
			</view> -->
			<view class="serch">
				<uni-search-bar class="input" radius="50" placeholder="搜索ID  或  手机号" clearButton="none"
					v-model="formData.keyword" cancelButton="none" @confirm="search" />
				<text class="screen" @click="openScreen">筛选 <text class="yticon icon-you"></text></text>
			</view>
		</view>
		<view class="body">
			<view class="list_item" v-for="(item,idx) in list" :key="idx">
				<view class="top">
					<image :src="item.avatar" mode=""></image>
					<view class="right">
						<view class="title">
							<text class="name">{{item.nickname}}</text>
							<!-- <text class="label" v-if="item.level==1">VIP</text> -->
							<!-- <text class="label label1" v-else>会员</text> -->
						</view>
						<view class="r_ul">
							<text>ID:{{item.id}}</text>
							<text>注册日期 {{item.createtime}}</text>
						</view>
						<view class="r_ul">
							<text>所属门店:<text class="color_2">{{item.supnum}}</text>家</text>
							<!-- <view><text class="color_2">{{item.rechargenum}}</text>家充值店</view> -->
						</view>
						<view class="r_ul">
							<text>直推人数:<text class="color_2">{{item.dirctnum}}</text>人</text>
							<text>团队人数:<text class="color_2">{{item.teamnum}}</text>人</text>						
						</view>
					</view>
				</view>
				<!-- <view class="l_info">
					<view class="b_left">
						<text>业务经理：</text>
						<text class="b_e" :class="{'red':item.issale=='是'}">{{item.issale}}</text>
					</view>
					<view class="b_left">
						<text>团队长：</text>
						<text class="b_e" :class="{'red':item.bonuslevel!='0'}" v-if="item.bonuslevel!=0">V{{item.bonuslevel}}</text>
						<text class="b_e" v-else>否</text>
					</view>
					<view @click="phoneCall(item.mobile)" class="color_2">联系他 ></view>
				</view> -->
				<view class="buttons">
					<!-- <text @click="$navTo('../user/empower?mid='+item.id)">授权身份</text> -->
					<!-- <text @click="$navTo('../user/dlconsume')">消费记录</text> -->
					<!-- <text>禁用</text> -->
				</view>
			</view>
			<view class="empty">
				<image v-if="isloading" src="../../static/business/loading.gif" mode=""></image>
				<text v-if="!ismore">到底了~</text>
			</view>
		</view>
		<uni-drawer ref="showRight" mode="right" :mask-click="true">
			<scroll-view class="scroll_screen" :scroll-y="true">
				<uni-forms :modelValue="formData" label-width="120px" label-position="top">
					<uni-forms-item label="注册起始日">
						<view class="data_time" @click="openPicker('begintime')">
							<text v-if="formData.begintime">{{formData.begintime}}</text>
							<text v-else>选择日期</text>
						</view>
					</uni-forms-item>
					<uni-forms-item label="注册截止日">
						<view class="data_time" @click="openPicker('endtime')">
							<text v-if="formData.endtime">{{formData.endtime}}</text>
							<text v-else>选择日期</text>
						</view>
					</uni-forms-item>
					<!-- <uni-forms-item label="店铺数量起">
						<uni-easyinput type="number" :clearable="false" v-model="formData.beginsupnum" placeholder="" />
					</uni-forms-item>
					<uni-forms-item label="店铺数量止">
						<uni-easyinput type="number" :clearable="false" v-model="formData.endsupnum"
							placeholder="" />
					</uni-forms-item> -->
					<view class="screen_submit">
						<button @click="screenSubmit">确定筛选</button>
					</view>
					<view class="block"></view>
				</uni-forms>
			</scroll-view>
		</uni-drawer>
		<simple-datetime-picker ref="myPicker" :startYear="2023" :isd="true" :endYear="endYear"
			@submit="handleSubmit"></simple-datetime-picker>
	</view>
</template>

<script>
	import SimpleDateTimePicker from '@/components/simple-datetime-picker/simple-datetime-picker.vue'
	export default {
		components: {
			SimpleDateTimePicker
		},
		data() {
			let date = new Date(),
				year = date.getFullYear();
			return {
				endYear: year,
				setDataTime: '',
				formData: {
					begintime: '',
					endtime: '',
					beginsupnum: '',
					endsupnum: '',
					keyword: ''
				},
				page: 0,
				list: [],
				isloading: false,
				ismore: true,
			}
		},
		onLoad() {
			this.getList();
		},
		onReachBottom() {
			this.getList();
		},
		methods: {
			getList() {
				this.page++;
				let obj = {
					...this.formData,
					page: this.page
				}
				this.isloading = true;
				this.ismore = true;
				this.$axios('customer/plist', 'POST', 'member', obj).then(res => {
					this.isloading = false;
					if (res.data.code == 200) {
						this.list = [...this.list, ...res.data.data];
						this.ismore = res.data.data.length > 0;
					}
				})
			},
			search() {
				this.page = 0;
				this.list = [];
				this.getList();
			},
			openScreen() {
				this.$refs.showRight.open();
			},
			screenSubmit() {
				this.$refs.showRight.close();
				this.search();
			},
			handleSubmit(e) {
				if (!this.setDataTime) return;
				this.formData[this.setDataTime] = `${e.year}-${e.month}-${e.day}`;
			},
			openPicker(v) {
				this.setDataTime = v;
				this.$refs.myPicker.show();
			},
			phoneCall(v) {
				uni.makePhoneCall({
					phoneNumber: v
				})
			},
		}
	}
</script>

<style lang="scss">
	page {
		background: #f2f2f2;
		color: #303133;
	}

	.wp {
		letter-spacing: 1px;
	}

	.nav_bar {
		background: #fff;
		position: fixed;
		top: calc(var(--window-top) + 0rpx);
		width: 100%;
		z-index: 100;

		.serch {
			display: flex;
			align-items: center;

			.input {
				flex: 1;
			}

			.screen {
				font-size: 32upx;
				padding-right: 10px;

				text {
					display: inline-block;
					transform: rotateZ(90deg);
				}
			}
		}

		.number {
			font-weight: bold;
			line-height: 24px;
			padding: 0 10px 10px;
		}
	}

	.body {
		// padding: 100px 0;
		padding: 66px 0;

		.list_item {
			background: #fff;
			border-radius: 15upx;
			margin-bottom: 10px;
			padding: 20upx;

			.top {
				display: flex;

				image {
					border-radius: 15upx;
					height: 135upx;
					width: 135upx;
				}

				.right {
					line-height: 45upx;
					padding-left: 20upx;
					width: calc(100% - 135upx);

					.title {
						color: #000;
						display: flex;
						align-items: center;
						font-size: 32upx;

						.label {
							background: #000;
							border-radius: 10upx;
							color: #f3dd91;
							font-size: 24upx;
							margin-left: 20upx;
							padding: 0 15upx;
						}

						.label1 {
							background: #f3dd91;
							color: #927419;
						}
					}

					.r_ul {
						display: flex;
						align-items: center;
						justify-content: space-between;
					}
				}
			}

			.l_info,
			.b_left {
				display: flex;
				align-items: center;
				justify-content: space-between;
			}

			.l_info {
				padding-top: 15upx;

				.b_left {
					justify-content: flex-start;

					.b_e {
						color: #999;
					}
					.red{
						color: red;
					}
				}
			}

			.l_label {
				color: #000;
				border-top: 1px #DCDFE6 solid;
				display: flex;
				align-items: center;
				justify-content: space-between;
				margin-top: 20upx;
				padding: 20upx 0;
			}

			.color_1 {
				color: $bg-color;
			}

			.color_2 {
				color: #8405dc;
			}

			.color_3 {
				color: #02883d;
			}

			.buttons {
				border-top: 1px #DCDFE6 solid;
				color: rgb(20, 15, 145);
				display: flex;
				align-items: center;
				justify-content: space-around;
				font-size: 32upx;
				margin-top: 20upx;

				text {
					flex: 1;
					padding: 30upx 0 10upx;
					text-align: center;
				}
			}
		}
	}

	.scroll_screen {
		height: 100vh;
	}

	.uni-forms {
		padding: 0 20upx;
	}

	.uni-forms .uni-forms-item__label {
		padding-bottom: 0 !important;
	}

	.uni-forms .uni-forms-item {
		margin-bottom: 10px;
	}

	.data_time {
		border: 1px solid #e5e5e5;
		border-radius: 4px;
		color: #666;
		font-size: 14px;
		height: 35px;
		line-height: 35px;
		padding: 0 10px;
	}

	.screen_submit {
		padding-top: 50upx;
		text-align: center;

		button {
			background: $bg-color;
			color: #fff;
			line-height: 90upx;
			height: 90upx;
			font-size: 34upx;
			letter-spacing: 1px;
		}
	}

	.block {
		height: 100upx;
	}

	.empty {
		image {
			height: 60upx;
			width: 60upx;
		}

		text-align: center;
		color: #4399fc;
	}
</style>